import request from '@/utils/request'

// 查询培养方案管理列表
export function listTrainingManagement(query) {
  return request({
    url: '/trainingManagement/trainingManagement/list',
    method: 'get',
    params: query
  })
}

// 查询培养方案管理详细
export function getTrainingManagement(id) {
  return request({
    url: '/trainingManagement/trainingManagement/' + id,
    method: 'get'
  })
}

// 新增培养方案管理
export function addTrainingManagement(data) {
  return request({
    url: '/trainingManagement/trainingManagement',
    method: 'post',
    data: data
  })
}

// 修改培养方案管理
export function updateTrainingManagement(data) {
  return request({
    url: '/trainingManagement/trainingManagement',
    method: 'put',
    data: data
  })
}

// 删除培养方案管理
export function delTrainingManagement(ids) {
  return request({
    url: '/trainingManagement/trainingManagement/' + ids,
    method: 'delete'
  })
}

// 根据培养方案id查询培养方案课程信息
// export function getTrainingManagementCourse(trainingProgramId) {
//   return request({
//     url: '/trainingManagement/trainingManagement' + trainingProgramId,
//     method: 'get'
//   })
// }
// 新增：一次性添加培养方案及其关联课程 (调用新的组合接口)
export function addTrainingProgramWithCourses(data) {
  return request({
    // !!! 确认这个 URL 和你后端 Controller 中的 @PostMapping 完全一致 !!!
    url: '/trainingManagement/trainingManagement/withCourses',
    method: 'post',
    data: data // 这个 data 应该是包含 program 和 courses 的 DTO 对象
  });
}

// 在API文件中添加更新接口函数updateTrainingProgramWithCourses
export function updateProgramWithCourses(data) {
  return request({
    url: '/trainingManagement/trainingManagement/withCourses',
    method: 'put',
    data: data
  })
}
export function updateStatusById(ids, status) {
  return request({
    url: '/trainingManagement/trainingManagement/updateStatusById',
    method: 'post',  // 将put改为post
    params: {
      ids: ids,
      status: status
    }
  })
}